bitkeeper revision 1.1203.1.1 (42150768_GVy_di2OIi0ljHAGVf4VA)
authormaf46@burn.cl.cam.ac.uk <maf46@burn.cl.cam.ac.uk>
Thu, 17 Feb 2005 21:06:48 +0000 (21:06 +0000)
committermaf46@burn.cl.cam.ac.uk <maf46@burn.cl.cam.ac.uk>
Thu, 17 Feb 2005 21:06:48 +0000 (21:06 +0000)
Be careful to continue using the 1:1 pagetable if we take a vmexit
before the vmx guest switches into protected/paged mode.

BitKeeper/etc/logging_ok
xen/arch/x86/shadow.c
xen/arch/x86/vmx.c
xen/arch/x86/vmx_io.c

index 5a2b880b665af19e35ea59105c712816956cea66..dd5943bb91d0759723fe6e745d9d7a3dd65c5798 100644 (file)
@@ -40,6 +40,7 @@ kaf24@striker.cl.cam.ac.uk
 kaf24@viper.(none)
 laudney@eclipse.(none)
 lynx@idefix.cl.cam.ac.uk
+maf46@burn.cl.cam.ac.uk
 mafetter@fleming.research
 mark@maw48.kings.cam.ac.uk
 maw48@labyrinth.cl.cam.ac.uk
index 90e19c5b084656628b3cd0cf1a0bc8e756a3b8dd..dadce938b8629ef56cf65e29a96aa69e5e0b921c 100644 (file)
@@ -260,7 +260,7 @@ static int shadow_mode_table_op(
     ASSERT(spin_is_locked(&d->arch.shadow_lock));
 
     SH_VLOG("shadow mode table op %p %p count %d",
-            pagetable_val(d->exec_domain[0]->arch.pagetable),    /* XXX SMP */
+            pagetable_val(d->exec_domain[0]->arch.guest_table),  /* XXX SMP */
             pagetable_val(d->exec_domain[0]->arch.shadow_table), /* XXX SMP */
             d->arch.shadow_page_count);
 
@@ -546,7 +546,7 @@ static void shadow_map_l1_into_current_l2(unsigned long va)
     if ( !(sl1ss & PSH_shadowed) )
     {
         /* This L1 is NOT already shadowed so we need to shadow it. */
-        SH_VVLOG("4a: l1 not shadowed ( %p )", sl1pfn);
+        SH_VVLOG("4a: l1 not shadowed ( %p )", sl1ss);
 
         sl1mfn_info = alloc_shadow_page(d);
         sl1mfn_info->u.inuse.type_info = PGT_l1_page_table;
@@ -618,7 +618,7 @@ int shadow_fault(unsigned long va, long error_code)
 
     SH_VVLOG("shadow_fault( va=%p, code=%ld )", va, error_code );
 
-    check_pagetable(d, ed->arch.pagetable, "pre-sf");
+    check_pagetable(d, ed->arch.guest_table, "pre-sf");
 
     /*
      * STEP 1. A fast-reject set of checks with no locking.
@@ -708,7 +708,7 @@ int shadow_fault(unsigned long va, long error_code)
 
     shadow_unlock(d);
 
-    check_pagetable(d, ed->arch.pagetable, "post-sf");
+    check_pagetable(d, ed->arch.guest_table, "post-sf");
     return EXCRET_fault_fixed;
 }
 
index dd53d5dbab0a6b080111a086714b0d3cbe2fb666..6b17946c7b8790a045305798c31c457fb75aa9a1 100644 (file)
@@ -114,6 +114,7 @@ static int vmx_do_page_fault(unsigned long va, unsigned long error_code)
     unsigned long eip;
     unsigned long gpa;
     int result;
+    struct exec_domain *ed = current;
 
 #if VMX_DEBUG
     {
@@ -124,6 +125,16 @@ static int vmx_do_page_fault(unsigned long va, unsigned long error_code)
     }
 #endif
 
+    /*
+     * If vpagetable is zero, then we are still emulating 1:1 page tables,
+     * and we should have never gotten here.
+     */
+    if ( !ed->arch.vpagetable )
+    {
+        printk("vmx_do_page_fault while still running on 1:1 page table\n");
+        return 0;
+    }
+
     gpa = gva_to_gpa(va);
     if (!gpa)
         return 0;
@@ -810,7 +821,8 @@ asmlinkage void vmx_vmexit_handler(struct xen_regs regs)
             break;
         }
         default:
-            __vmx_bug(&regs);
+            printk("unexpected VMexit for exception vector 0x%x\n", vector);
+            //__vmx_bug(&regs);
             break;
         }
         break;
index 9fbaa05298641f30cf3af185214a2657c3100d3f..e7f80bed455b6bec81444b62f6e53b2648ce0441 100644 (file)
@@ -380,8 +380,13 @@ void vmx_intr_assist(struct exec_domain *d)
 
 void vmx_do_resume(struct exec_domain *d) 
 {
+    if ( d->arch.vpagetable )
+        __vmwrite(GUEST_CR3, pagetable_val(d->arch.shadow_table));
+    else
+        // we haven't switched off the 1:1 pagetable yet...
+        __vmwrite(GUEST_CR3, pagetable_val(d->arch.guest_table));
+
     __vmwrite(HOST_CR3, pagetable_val(d->arch.monitor_table));
-    __vmwrite(GUEST_CR3, pagetable_val(d->arch.shadow_table));
     __vmwrite(HOST_ESP, (unsigned long)get_stack_bottom());
 
     if (event_pending(d)) {